﻿@using NetCoreCMS.Framework.Core.Models.ViewModels
@model StartupViewModel

@{
    Layout = Constants.AdminLayoutName;
    Title = "Startup";
    SubTitle = "Set Startup Page";
}

<div class="">
    @if(ViewBag.Message != null)
    {
        <div class="alert alert-danger">@ViewBag.Message</div>
    }  
</div>
 
     
<div class="">
    <div id="exTab1" class="">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#siteStartupTab" data-toggle="tab">Site Startup</a>
            </li>
            <li>
                <a href="#roleStartupTab" data-toggle="tab">Role Startup</a>
            </li>
        </ul>

        <div class="tab-content clearfix">
            <div class="tab-pane fade in active" id="siteStartupTab">
                <form class="form-horizontal" asp-controller="@ControllerName" asp-action="Startup" method="post">

                    <div class="form-group">
                        <div class="col-sm-1"></div>
                        <div class="col-sm-5"><h3>Select Website Startup Page</h3></div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="StartupType" value="Url" @ViewBag.DefaultChecked /></div>
                        <div class="col-sm-5"><input type="text" name="Url" value="@Model.Url" class="form-control" /></div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="StartupType" value="Page" @ViewBag.PageChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="PageId" asp-items="@Model.Pages" class="form-control">
                                <option>Select a page</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="StartupType" value="Category" @ViewBag.CategoryChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="CategoryId" asp-items="@Model.Categories" class="form-control">
                                <option>Select a category</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="StartupType" value="Post" @ViewBag.PostChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="PostId" asp-items="@Model.Posts" class="form-control">
                                <option>Select a post</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="StartupType" value="Module" @ViewBag.ModuleChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="ModuleSiteMenuUrl" asp-items="@Model.ModuleSiteMenus" class="form-control">
                                <option>Select module menu</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-1"></div>
                        <div class="col-sm-5"><input class="btn btn-primary" type="submit" value="Update" /></div>
                    </div>
                </form>
            </div>
            <div class="tab-pane fade in" id="roleStartupTab">
                <div class="row">
                <form class="form-horizontal" asp-controller="Admin" asp-action="RoleStartup" method="post">

                    <div class="form-group">
                        <div class="col-sm-1"></div>
                        <div class="col-sm-5"><h3>Startup Page according to User Role</h3></div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right">Roles</div>
                        <div class="col-sm-5">
                            <select asp-for="Roles" asp-items="@Model.Roles" class="form-control">                                
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="RoleStartupType" value="Url" @ViewBag.DefaultChecked /></div>
                        <div class="col-sm-5"><input type="text" name="Url" value="@Model.Url" class="form-control" /></div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="RoleStartupType" value="Page" @ViewBag.PageChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="PageId" asp-items="@Model.Pages" class="form-control">
                                <option>Select a page</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="RoleStartupType" value="Category" @ViewBag.CategoryChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="CategoryId" asp-items="@Model.Categories" class="form-control">
                                <option>Select a category</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="RoleStartupType" value="Post" @ViewBag.PostChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="PostId" asp-items="@Model.Posts" class="form-control">
                                <option>Select a post</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-1 text-right"><input type="radio" name="RoleStartupType" value="Module" @ViewBag.ModuleChecked /></div>
                        <div class="col-sm-5">
                            <select asp-for="ModuleSiteMenuUrl" asp-items="@Model.ModuleSiteMenus" class="form-control">
                                <option>Select module menu</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-1"></div>
                        <div class="col-sm-5"><input class="btn btn-primary" type="submit" value="Update" /></div>
                    </div>
                </form>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                Role Startup Page
                            </div>
                            <div class="panel-body">
                                <table id="pageListDt" class="table table-striped table-bordered" cellspacing="0" width="100%">
                                    <thead>
                                        <tr>
                                            <th>Role</th>
                                            <th>For</th>
                                            <th>Type</th>
                                            <th>Url</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var startup in ViewBag.RoleStartups)
                                        {
                                            <tr>
                                                <td>@startup.Permission.Name</td>
                                                <td>@startup.StartupFor</td>
                                                <td>@startup.StartupType</td>
                                                <td>@startup.StartupUrl</td>                                                
                                                <td>                                                    
                                                    <a asp-controller="@ControllerName" asp-action="DeleteRoleStartup" asp-route-id="@startup.Id">Delete</a>
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>

                            </div>
                            <!-- /.panel-body -->
                        </div>
                        <!-- /.panel -->
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>


@section Scripts{
    <link href="~/lib/DataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <link href="~/lib/DataTables/jquery.dataTables.min.css" rel="stylesheet" />
    <script src="~/lib/DataTables/jquery.dataTables.min.js"></script>
    <script src="~/lib/DataTables/dataTables.bootstrap.min.js"></script>
}


